package com.ran.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class MessageResult<T> {
    private int code;
    private String message;
    private T data;

    // 成功响应构造方法
    public static <T> MessageResult<T> success(T data) {
        return new MessageResult<>(200, "Success", data);
    }
    public static <T> MessageResult<T> success(int code, String message) {
        return new MessageResult<>(code, message, null);
    }

    // 失败响应构造方法
    public static <T> MessageResult<T> error(int code, String message) {
        return new MessageResult<>(code, message, null);
    }

}
